package ph.loong.deliveryman.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.EditText;

import deliveryman.loong.ph.deliveryman.R;

/**
 * Author jc.lu.
 * Dates 2018/2/22.
 * Email Tbsupland@163.com.
 * desc
 */

public class VerifyCodeDialog extends Dialog {
    public VerifyCodeDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_verify_code);
        initView();
    }

    private void initView() {
        findViewById(R.id.btn_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                VerifyCodeDialog.this.dismiss();
            }
        });

        findViewById(R.id.btn_confirm).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                EditText verifyCode = findViewById(R.id.et_check_code);
                String verifyCodeText = verifyCode.getText().toString();
                if (mVerifyCodeClickItem != null) {
                    mVerifyCodeClickItem.setOnConfirmClick(verifyCodeText);
                }
                VerifyCodeDialog.this.dismiss();
            }
        });
    }

    private VerifyCodeClickItem mVerifyCodeClickItem;

    public interface VerifyCodeClickItem {
        void setOnConfirmClick(String str);
    }

    public void setVerifyCodeClickItem(VerifyCodeClickItem verifyCodeClickItem) {
        this.mVerifyCodeClickItem = verifyCodeClickItem;
    }
}
